package com.pmdesigns.sqlmapper;


/**
 * Simple structure representing a join table
 * and one of the models refered to by the join table
 * <p>
 * It is intened that its public fields be accessed directly from java-code-tags
 * and java-expression-tags in template files.
 * <p>
 * Here is an example of an annotate join table:
 * <pre>
 * CREATE TABLE student_courses (      -- @model(join)
 *     student_id integer,             -- @field(has1=Student)
 *     course_id integer               -- @field(has1=Course)
 * );
 * </pre>
 *
 * This would produce 2 JoinedModels, one belonging to the Student model
 * and the other belonging to the Course model.
 *
 * @author mike dooley
 */
public class JoinedModels {
	/**
	 * The table defining this join.
	 */
	public final Model joinedBy;
	
	/**
	 * The model that the <em>thatKey</em> field points to.
	 */
	public final Model joinedTo;

	/**
	 * The field in the <em>joinedBy</em> table which <em>does not</em> point to the <em>joinedTo</em> model.
	 */
	public final Field thisKey;

	/**
	 * The field in the <em>joinedBy</em> table which points to the <em>joinedTo</em> model.
	 */
	public final Field thatKey;

	
	JoinedModels(Model joinedBy, Field thisKey, Field thatKey, Model joinedTo) {
		this.joinedBy = joinedBy;
		this.joinedTo = joinedTo;
		this.thisKey = thisKey;
		this.thatKey = thatKey;
	}
}
